<template>
  <div class="adminHandle" >
    <h2>教师课程查询</h2>

    <div class="tablelist">
      <template>
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            prop="id"
            label="课程id"
            width="90">
          </el-table-column>
          <el-table-column
            prop="name"
            label="名称"
            width="180">
          </el-table-column>
          <el-table-column
            prop="rid"
            label="教室id"
            width="90">
          </el-table-column>
          <el-table-column
            prop="book"
            label="课程教材"
            width="360">
          </el-table-column>
          <el-table-column
            prop="weeksOfTerm"
            label="课程周数">
          </el-table-column>
          <el-table-column
            prop="week"
            label="上课日期">
          <template slot-scope="scope">
            <div>星期{{scope.row.week}}</div>
          </template>
          </el-table-column>
          <el-table-column
            prop="section"
            label="上课节数">
            <template slot-scope="scope">
              <div>{{classAt(scope.row.section)}}</div>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
  </div>
</template>




<script>
import axios from 'axios'

export default {
  name: "TeacherCourseInfo",
  data(){
    return{
      tableData:[],
    }
  },
  computed:{
    classAt: function(){
      return function(num){
      if(num === "1"){return "第一二节"}
      else if(num === "2"){return "第三四节"}
      else if(num === "3"){return "第五六节"}
      else{return "第七八节"}}

    },
  },
  mounted() {
    this.ip = localStorage.getItem('ip',)
    this.token = sessionStorage.getItem('token')

    axios.defaults.headers.common["token"] = this.token;
    axios.get((this.ip + '/course/teacher')).then((response)=>{
      this.tableData = response.data
      console.log(response.data)
    }).catch((error)=>{
      console.log(error)
    })
  }
}
</script>


<style scoped>
.adminHandle{
  width: 100%;
  padding: 5px 10px 0px 10px;
  margin: 20px 100px 0px 100px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3);

}
</style>

